package com.example.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.example.entity.supervision.ElevatorUsedInspection;
import com.example.mapp.ElevatorUsedInspectionMapp;
import com.example.service.ElevatorUsedInspectionService;
import com.example.util.ResultUtil;

import ch.qos.logback.classic.Logger;

/**
 * Created by douyx on 2018/03/26.
 */
@Service
public class ElevatorUsedInspectionServiceImpl implements ElevatorUsedInspectionService {

	private final static Logger logger = (Logger) LoggerFactory.getLogger(ElevatorUsedInspectionServiceImpl.class);

	@Autowired
	private ElevatorUsedInspectionMapp elevatorUsedInspectionMapp;

	@Override
	public Map<String, Object> add(ElevatorUsedInspection elevatorUsedInspection) {
		try {
			elevatorUsedInspectionMapp.add(elevatorUsedInspection);
			Map<String, Object> map = new HashMap<>();
			map.put("elevatorControlId", elevatorUsedInspection.getId());
			return ResultUtil.returnSuccess("提交成功", map);
		} catch (Exception e) {
			logger.error(e.getMessage());
			return ResultUtil.returnError("提交失败" + e.getMessage(), null);
		}
	}

	@Override
	public Map<String, Object> query(String id) {
		try {
			ElevatorUsedInspection elevatorUsedInspection = elevatorUsedInspectionMapp.query(id);
			return ResultUtil.returnSuccess("提交成功", elevatorUsedInspection);
		} catch (Exception e) {
			logger.error(e.getMessage());
			return ResultUtil.returnError("提交失败" + e.getMessage(), null);
		}
	}

}
